<extend name="Public/base"/>

<block name="body">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title">
        <!--<h2>{$info['id']?'编辑':'新增'}轮播图</h2>-->
        <h2>新增分类</h2>
    </div>
    <form action="{:U('Goodsbrand/add')}" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">品牌名称</label>
            <div class="controls">
                <input type="text" class="text input-large" name="name" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">品牌网址</label>
            <div class="controls">
                <input type="text" class="text input-large" name="url" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">品牌分类<span class="check-tips">（网站)</span></label>
            <div class="controls">
                <select name="type">
                        <!--<option value="0">顶级分类</option>-->
                    <volist name="Menus" id="menu">
                        <option value="{$menu.id}">{$menu.title_show}{$menu.name}</option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">排序<span class="check-tips">（用于分组显示的顺序）</span></label>
            <div class="controls">
                <input type="text" class="text input-small" name="rank" value="{$info.rank|default=0}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">是否推荐<span class="check-tips"></span></label>
            <div class="controls">
                <label class="radio"><input type="radio" name="recommend" value="0">否</label>
                <label class="radio"><input type="radio" name="recommend" value="1">是</label>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">品牌描述</label>
            <div class="controls">
                <input type="text" class="text input-large" name="remark" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">品牌logo<span class="check-tips">(注意同名覆盖)</span></label>
            <div class="controls">
                <div class="controls">
                    <!--图片上传-->
                    <div class="controls">
                        <input type="file" id="upload_picture_pic">
                        <input type="hidden" name="picture" id="cover_id_pic"/>
                        <input type="hidden" name="logo" id="cover_logo"/>
                        <!--<input type="hidden" name="logo_path" id="cover_id_path"/>-->
                        <!--<input type="hidden" name="logo_savename" id="cover_id_savename"/>-->
                        <div class="upload-img-box"></div>
                    </div>
                </div>
                <script type="text/javascript">
                    //上传图片
                    /* 初始化上传插件 */
                    $("#upload_picture_pic").uploadify({
                        "height"          : 30,
                        "swf"             : "__STATIC__/uploadify/uploadify.swf",
                        "fileObjName"     : "download",
                        "buttonText"      : "上传图片",
                        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id(),'setpath'=>'LOGO_PICTURE_UPLOAD'))}",
                        "width"           : 120,
                        'removeTimeout'	  : 1,
                        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                        "onUploadSuccess" : uploadPicturepic
                    });
                    function uploadPicturepic(file, data){
                        var data = $.parseJSON(data);
                        var src = '';
                        if(data.status){
                            $("#cover_id_pic").val(data.id);
                            $("#cover_id_savename").val(data.savename);
                            src = data.url || '__ROOT__' + data.path
                            $("#cover_logo").val(src);
                            $("#cover_id_path").val(src.replace(data.savename,'') + '');
                            $("#cover_id_pic").parent().find('.upload-img-box').html(
                                    '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                            );
                        } else {
                            updateAlert(data.info);
                            setTimeout(function(){
                                $('#top-alert').find('button').click();
                                $(that).removeClass('disabled').prop('disabled',false);
                            },1500);
                        }
//                        console.log(data);
//                        console.log(file);
                    }

                </script>
            </div>
        </div>

        <div class="form-item">
            <button class="btn submit-btn" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
//        Think.setValue("pid", {$info.pid|default = 0});
        Think.setValue("recommend", 0);
        //导航高亮
        $('.side-sub-menu').find('a[href="{:U('index')}"]').closest('li').addClass('current');
    </script>
</block>
